package factory1;

import cn.hutool.core.util.StrUtil;

/**
 * @Author: 582895699@qq.com
 * @Desctription: 工厂模式
 * @Date: Created in 2021/12/10 17:24
 */
public class ShapeFactory {

    public Shape getShape(String type) {
        if (StrUtil.isEmpty(type)) {
            System.out.println("type is null");
            return null;
        }

        if ("Rectangle".equalsIgnoreCase(type)) {
            return new Rectangle();
        }

        if ("Square".equalsIgnoreCase(type)) {
            return new Square();
        }

        if ("Circle".equalsIgnoreCase(type)) {
            return new Circle();
        }
        return null;
    }

    public static void main(String[] args) {
        ShapeFactory shapeFactory = new ShapeFactory();
        Shape rectangle = shapeFactory.getShape("Rectangle");
        rectangle.draw();

    }
}
